package com.hui10.mediaplayer.util

import com.hui10.mediaplayer.R
import com.hui10.mediaplayer.base.BaseFragment
import com.hui10.mediaplayer.ui.fragment.HomeFragment
import com.hui10.mediaplayer.ui.fragment.MvFragment
import com.hui10.mediaplayer.ui.fragment.VbangFragment
import com.hui10.mediaplayer.ui.fragment.YueDanFragment

/**
 * Author: Created by lucus on 2019/5/24.
 * E-mail: mcphilex1989@gmail.com
 * Tel: 15652608401
 */
class FragmentUtil private constructor() {

    private val homeFragment by lazy {
        HomeFragment()
    }

    private val mvFragment by lazy {
        MvFragment()
    }

    private val vbangFragment by lazy {
        VbangFragment()
    }

    private val yueDanFragment by lazy {
        YueDanFragment()
    }

    companion object {
        private val fragmentUtil by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            FragmentUtil()
        }

        fun get(): FragmentUtil {
            return fragmentUtil
        }
    }

    fun getFragmentById(tabId: Int): BaseFragment? {
        when (tabId) {
            R.id.tab_home -> return homeFragment
            R.id.tab_mv -> return mvFragment
            R.id.tab_vbang -> return vbangFragment
            R.id.tab_yuedan -> return yueDanFragment
        }
        return null
    }
}